<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <script>
      let name = "Jack";
      let age = 18;
      let gender = "男";

      const obj = {
        name: name,
        age: age,
        gender: gender,
      };
      console.log(obj);

      /* key-value同名时可以简写 */
      const obj2 = {
        //key-value同名 直接使用简写
        name,
        age,
        gender,
      };
      console.log(obj2);

      const obj3 = {
        name: "穆铁柱3",
        sayHello: function () {
          console.log("sayHello", this); //obj3
        },
      };
      obj3.sayHello();

      /* 函数的简写 */
      const obj4 = {
        name: "穆铁柱4",

        // 【常规函数】的简写
        sayHello() {
          console.log("sayHello", this); //obj4
        },
      };
      obj4.sayHello();
    </script>
  </body>
</html>
